<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>塞纳皇宫-网站后台管理系统</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/static/admin/img/logo.png" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico"> <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/static/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="/static/admin/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <script src="/static/admin/js/city/jquery-1.11.3.min.js"></script>

    <!-- 全局/static/admin//static/admin//static/admin/js -->
    <script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="/static/admin/js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <!-- <script src="/static/admin/js/plugins/validate/jquery.validate.min.js"></script>-->
    <!--<script src="/static/admin/js/plugins/validate/messages_zh.min.js"></script>-->
    <!--<script src="/static/admin/js/demo/form-validate-demo.js"></script>-->
    <script src="/static/admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>

    <!--script src="/static/admin/layer/layer.css"></script>-->
    <script src="/static/admin/layer/layer.js"></script>
    <style>

        .uploadbtn{position: absolute;padding: 5px 10px;background: #23b7e5;border-radius: 5px;color: #ffffff;z-index: 4}
        .uploadbtn:hover{background: #19a9d5;cursor: pointer;}
        .form-control{cursor: pointer;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>咨询配置</h5>
                </div>

            </div>
        </div>
    </div>

    <div class="ibox-content">
        <form class="form-horizontal m-t" id="company-form" action="" method="post" onsubmit="return subForm()"  enctype="multipart/form-data" >
            <input name="id" id="id" value="{if isset($data)}{$data.id}{/if}" type="hidden">
            <div class="form-group">
                <label class="col-sm-1 control-label">标题：</label>
                <div class="col-sm-2">
                    <input id="title" name="title"  class="form-control" type="text" required=""  value="{if isset($data)}{$data.title}{/if}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">广告图：</label>
                <div class="col-sm-2">
                    <input id="consult_banner"   style="padding: 0;position: absolute; opacity: 0;z-index: 3 ;cursor: pointer;width:20px;" class="form-control" type="file" name="consult_banner" onchange="uploadImg(this,'imgupload')">
                    <p class="uploadbtn" >点击上传图片</p>
                    <input type="hidden" name="consult_banner" value="{if isset($data)}{$data.consult_banner}{/if}" >
                    {if isset($data.consult_banner) && $data.consult_banner !=='' }
                    <img id ="imgupload"  class='willshow' src="{if isset($data)}{$data.consult_banner}{/if}" style=" display:block;max-height: 200px;margin-top: 32px"/>
                    {else}
                    <img id ="imgupload"  class='willshow' src="" style=" display:none;max-height: 200px;margin-top: 32px"/>
                    {/if}
                </div>
                <!--{if isset($data.consult_banner) && $data.consult_banner!==''}
                <div style="margin-top: 6px;"><a target="_blank" href="{if isset($data) }{$data.consult_banner}{/if}">查看原图</a></div>
                {else}
                <div style="margin-top: 6px;"><a>暂无图片</a></div>
                {/if}-->
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label">显示状态：</label>
                <div style="margin-left: 20px;" class="radio radio-info radio-inline">
                    <input type="radio" id="inlineRadio1" value="1" name="is_show" checked="" {if isset($data) && $data.is_show ==1 }checked{/if}>
                    <label for="inlineRadio1"> 显示</label>
                </div>
                <div style="margin-left: 35px;" class="radio radio-inline radio-danger">
                    <input type="radio" id="inlineRadio2" value="0" name="is_show" {if isset($data) && $data.is_show ==0 }checked{/if}>
                    <label for="inlineRadio2"> 不显示</label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">拍摄风格设置：</label>
                <div class="col-sm-2" id="ps-style">
                    {if isset($data.ps_style)}
                        {volist name="$data.ps_style" id="v"}
                    <div class="input-group" style="margin-top: 10px;" >
                        <input  name="ps_style[]"  class="form-control" type="text" required=""  value="{$v}">
                        <span  onclick="del_scene(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>
                    </div>
                         {/volist}
                    {else}
                        <input style="margin-top: 10px;"  name="ps_style[]"  class="form-control" type="text" required=""  value="">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2" style="margin-left: 140px; ">
                    <button class="btn btn-primary" onclick="click_style()" ><span style="color: white;">+</span></button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">礼服数量设置：</label>
                <div class="col-sm-2" id="ps-lf">
                    {if isset($data.clothes_num)}
                        {volist name="$data.clothes_num" id="v"}
                    <div class="input-group" style="margin-top: 10px;">
                        <input  name="clothes_num[]"  class="form-control" type="text" required=""  value="{$v}">
                        <span  onclick="del_style(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>
                    </div>
                        {/volist}
                    {else}
                         <input style="margin-top: 10px;"  name="clothes_num[]"  class="form-control" type="text" required=""  value="">
                    {/if}

                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2" style="margin-left: 140px; ">
                    <button onclick="click_lf()" class="btn btn-primary"><span style="color: white;">+</span></button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">相框数量设置：</label>
                <div class="col-sm-2" id="ps-xk">
                    {if isset($data.xg_num)}
                        {volist name="$data.xg_num" id="v"}
                            <div class="input-group" style="margin-top: 10px;">
                                <input  name="xg_num[]"  class="form-control" type="text" required=""  value="{$v}">
                                <span  onclick="del_plan(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>
                            </div>
                        {/volist}
                    {else}
                        <input style="margin-top: 10px;"  name="xg_num[]"  class="form-control" type="text" required=""  value="">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2" style="margin-left: 140px; ">
                    <button onclick="click_xk()" class="btn btn-primary"><span style="color: white;">+</span></button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">相册数量设置：</label>
                <div class="col-sm-2" id="ps-xc">
                    {if isset($data.xc_num)}
                    {volist name="$data.xc_num" id="v"}
                    <div class="input-group" style="margin-top: 10px;">
                        <input  name="xc_num[]"  class="form-control" type="text" required=""  value="{$v}">
                        <span  onclick="del_plan(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>
                    </div>
                    {/volist}
                    {else}
                    <input style="margin-top: 10px;"  name="xc_num[]"  class="form-control" type="text" required=""  value="">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2" style="margin-left: 140px; ">
                    <button onclick="click_xc()" class="btn btn-primary"><span style="color: white;">+</span></button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">简介：</label>
                <div class="col-sm-3">
                    <textarea style="height: 100px;" id="intro"  class="form-control"  aria-required="true" name="intro">{if isset($data)}{$data.intro}{/if}</textarea>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-8 col-sm-offset-3">
                    <button class="btn btn-primary" type="submit" >提交</button>
                </div>
            </div>

        </form>
    </div>
</div>
</div>
</div>

</div>

<script src="/static/admin/js/city/area.js"></script>
<script src="/static/admin/js/city/select.js"></script>

<script  type="text/javascript">
    $(function(){
        $('.uploadbtn').click(function(){
            return $('#consult_banner').click();
        })
    })

    function click_style(){
        var str =   '<div class="input-group" style="margin-top: 10px;">' +
                    '<input  name="ps_style[]"  class="form-control" type="text" required=""  value="">' +
                    '<span  onclick="del_scene(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>' +
                    '</div>';
        $("#ps-style").append(str);
    }
    function click_lf(){
        var str =   '<div class="input-group" style="margin-top: 10px;">' +
            '<input  name="clothes_num[]"  class="form-control" type="text" required=""  value="">' +
            '<span  onclick="del_style(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>' +
            '</div>';
        $("#ps-lf").append(str);
    }
    function click_xk(){
        var str =   '<div class="input-group" style="margin-top: 10px;">' +
            '<input  name="xg_num[]"  class="form-control" type="text" required=""  value="">' +
            '<span  onclick="del_plan(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>' +
            '</div>';
        $("#ps-xk").append(str);
    }
    function click_xc(){
        var str =   '<div class="input-group" style="margin-top: 10px;">' +
            '<input  name="xc_num[]"  class="form-control" type="text" required=""  value="">' +
            '<span  onclick="del_plan(this)" class="input-group-addon"><i class=" fa fa-trash-o"></i> </span>' +
            '</div>';
        $("#ps-xc").append(str);
    }
    function del_scene(obj){
        $(obj).parents('.input-group').remove();
    }
    function del_style(obj){
        $(obj).parents('.input-group').remove();
    }
    function del_plan(obj){
        $(obj).parents('.input-group').remove();
    }

    function uploadImg(file, showImg) {
        if (!file.files[0]) {
            return false;
        }
        if (!file.value.match(/.jpg|.gif|.png|.jpeg/i)) {
            layer.msg('您选择的图片格式不正确，请重新选择');
            return false;
        }
        if (file.files[0].size > 1 * 1024 * 1024) {
            layer.msg('您选择的图片不能大于1M，请重新选择！');
            return false;
        }
        var myPhoto = document.getElementById(showImg);
        var reader = new FileReader();
        reader.onload = function (e) {
            var dataURL = e.target.result;
            myPhoto.src = dataURL;
            myPhoto.style.display = 'block';
        };
        reader.readAsDataURL(file.files[0]);

    }

    function subForm(){
        var formobj = document.getElementById('company-form')
        var formData = new FormData(formobj);
        var title = $("#title").val();
        if(title ==''){
            layer.msg('请输入标题');
            return false;
        }
        $.ajax({
            url:"/mobile.php/consult/add_config",
            data:formData,
            type:"post",
            dataType:'json',
            processData: false,  // 告诉jQuery不要去处理发送的数据
            contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
            success:function(res){
                if(1==res.code) {
                    layer.msg(res.msg);
                    setTimeout(function(){
                        window.location.reload();
                    },1000)
                }else{
                    layer.msg(res.msg);
                    return false;
                }
            },
            error:function(){
                layer.msg('系统错误');
                return false;
            },

        })
        return false;
    }

</script>
</body>


</html>
